require(['/js/config.js'],()=>{
    require(['template','url','swiper','header','footer'],(template,url,Swiper)=>{
        class Index{
            constructor(){
                this.getGoodsInfo()
                this.banner()
                
            }
            getGoodsInfo(){
                $.get('/libs/json/indexgoods.json',resp=>{
                    this.renderGoodsInfo(resp)
                })
            }
            renderGoodsInfo(list){
                const html = template('indexgoods', { list :list })
                $('#indexGoodsList').html(html)
                this.gotoMall()
            }
            banner(){
                new Swiper ('.swiper-container', {
                    loop: true, // 循环模式选项
                    
                    // 如果需要分页器
                    pagination: {
                      el: '.swiper-pagination',
                    },
                    
                    // 如果需要前进后退按钮
                    navigation: {
                      nextEl: '.swiper-button-next',
                      prevEl: '.swiper-button-prev',
                    },
                    
                    autoplay: {
                        delay: 2000,
                        stopOnLastSlide: false,
                        disableOnInteraction: true,
                    }
                    
                  })    
            }
            gotoMall(){
                $('.gotoMall').on('click',()=>location.replace('/html/mall.html'))
                
                
            }
            
        }
        new Index()
    })
})